package com.china08.yxyapi.api.manage.edu.platform.news;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.cache.YxCacheUtil;
import com.china08.yxyapi.entity.mg.platform.YxyHomeNews;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.YxyHomeNewsRepository;

import io.swagger.annotations.ApiOperation;

/**
 * 教育局平台办公 新闻管理 删除
 * 
 */
@CrossOrigin
@RestController
public class NewsDelController extends YxyApiBaseController {

    @Autowired
    private YxyHomeNewsRepository yhnr;

    @ApiOperation(value = "教育局删除咨询")
    @RequestMapping(value = "/api_yw/manage/edu/platform/news/del/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(@PathVariable(value = "id") String id) {
        RespModel model = new RespModel();
        YxyHomeNews homeNews = yhnr.findById(id);
        if (homeNews != null) {
            homeNews.setStatus(-1);
            yhnr.save(homeNews);
        }
        model.setMessage("成功");
        YxCacheUtil.eviceCacheAll();
        return model;
    }

    protected static class RespModel extends YxyApiRespModel {

    }

}